package com.angzh.bolibao.common;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

public class Util {
	
	public static final Logger logger = Logger.getLogger(Util.class);

	/**
	 * 获取一个返回给前端的对象用来生成json
	 * 
	 * @return
	 */
	public static final Map<String, Object> getRetJson() {
		return getRetJson(500, "server error");
	}

	public static final Map<String, Object> getOkRetJson() {
		return getRetJson(200, "ok");
	}

	public static final Map<String, Object> getOkRetJson(String msg) {
		return getRetJson(200, msg);
	}

	public static final Map<String, Object> getErrorRetJson(String msg) {
		return getRetJson(500, msg);
	}

	public static final Map<String, Object> getForbbidenRetJson(String msg) {
		return getRetJson(403, msg);
	}

	public static final Map<String, Object> getRetJson(Integer code, String msg) {
		Map<String, Object> retJson = new HashMap<String, Object>();
		retJson.put("code", code);
		retJson.put("msg", msg);
		return retJson;
	}

}
